package com.huaxin.hxmoduleworkorder.common.validator;

import com.huaxin.hxmoduleworkorder.common.annotation.validation.ValidOrderType;
import com.huaxin.hxmoduleworkorder.common.enums.OrderType;
import jakarta.validation.ConstraintValidator;
import jakarta.validation.ConstraintValidatorContext;

public class OrderTypeValidator implements ConstraintValidator<ValidOrderType, String> {
    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        if (value == null || value.trim().isEmpty()) {
            return true; // null 或纯空白都跳过校验
        }
        return OrderType.isValid(value);
    }
}
